package com.example.routeplansystem.dao;

import com.example.routeplansystem.entity.po.Edges;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author lucong
 * @Date 2022/6/24
 * @Description
 */
@Repository("EdgesDao")
public interface EdgesDao {

    @Insert({
            "insert into edges (from_node,to_node,distance)",
            "values (#{from},#{to},#{distance})"
    })
    int insert(int from, int to, int distance);


    @Select({
            "<script>",
            "SELECT id,from_node,to_node,distance from edges ",
            "where",
            "from_node in ",
            "<foreach collection='list' item='id' open='(' close=')' separator=','>",
            "#{id}",
            "</foreach>",
            "and",
            "to_node in ",
            "<foreach collection='list' item='id' open='(' close=')' separator=','>",
            "#{id}",
            "</foreach>",
            "</script>"
    })
    List<Edges> findNodes(List<Integer> nodeIdList);

    Integer selectDisInt(Integer startId, Integer endId);


}
